<?php
namespace app\app\storage;

use app\common\storage\Login as ParentStorage;

/**
 * 非直接读取数据库存储
 */
class Login extends ParentStorage {
	//获取token
	public function get_token($options) {
		$route = $this->request->get_route();
		$options['login_type'] = $route;

		$username = $options['username'];
		$token = $this->openid2token($username);
		$options['unionid'] = loadOnly('tyyh\\User')->unionid4username($username);		

		$redis = loader()->loadAny('redis', 'Redis');
		$redis->setArray($route . '_' . $token, $options, config('login.expires'));

		return $token;
	}
}
